/// <reference path="../../node_modules/@types/underscore/index.d.ts" />
import {BrowserModule} from '@angular/platform-browser';
import {InjectionToken, NgModule} from '@angular/core';
import {DatePipe, registerLocaleData} from '@angular/common';
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from '@angular/common/http';
import zh from '@angular/common/locales/zh';
import {AppComponent} from './app.component';
import {LoginComponent} from './components/login/login.component';
import {RoutesModule} from './modules/routes/routes.module';
import {MainComponent} from './components/main/main.component';
import {NavbarComponent} from './components/main/navbar/navbar.component';
import {MenuComponent} from './components/main/menu/menu.component';
import {MenuItemComponent} from './components/main/menu/menu-item/menu-item.component';
import {ContentComponent} from './components/main/content/content.component';
import {
  NgToolsModule,
  serverConfigFactory,
  ServerConfigService,
  TokenInterceptorService, UnitPipe
} from '../ng-tools';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {AppMessageRegisterModule} from './modules/message-register/message-register.module';

import {ContextPipe} from './pipes/context-pipe';
import {MenuService} from './services/api/menu.service';
import {ServerTimeService} from './services/server-time.service';
import {CnTransPipe} from './pipes/cn-trans';

import {ThemeComponent} from './components/theme/theme.component';
import {ThemeService} from './services/theme.service';
import {CopyrightComponent} from './components/copyright/copyright.component';
import {UserService} from './services/api/user.service';
import { PlatformInfoComponent } from './components/main/content/platform-info/platform-info.component';
import { UserManagerComponent } from './components/main/content/user-manager/user-manager.component';
import { ChargeManagerComponent } from './components/main/content/charge-manager/charge-manager.component';
import { ChargeRecordComponent } from './components/main/content/charge-record/charge-record.component';
import { MoneyManagerComponent } from './components/main/content/money-manager/money-manager.component';
import { MoneyRecordComponent } from './components/main/content/money-record/money-record.component';
import { EditNoticeComponent } from './components/main/content/platform-info/edit-notice/edit-notice.component';
import { UserServiceComponent } from './components/main/content/platform-info/user-service/user-service.component';
import { UserBankComponent } from './components/main/content/platform-info/user-bank/user-bank.component';
import { SystemSetComponent } from './components/main/content/system-set/system-set.component';
import { GameGroupComponent } from './components/main/content/game-group/game-group.component';
import { RobotGroupComponent } from './components/main/content/robot-group/robot-group.component';
import { RobotManagerComponent } from './components/main/content/robot-manager/robot-manager.component';
import { RobotEditComponent } from './components/main/content/robot-edit/robot-edit.component';
import { RobotProduceComponent } from './components/main/content/robot-produce/robot-produce.component';
import { RobotGroupListComponent } from './components/main/content/robot-group-list/robot-group-list.component';
import { RobotGroupItemAddComponent } from './components/main/content/robot-group-item-add/robot-group-item-add.component';
import { RobotGroupItemConfigComponent } from './components/main/content/robot-group-item-config/robot-group-item-config.component';
import { GameGroupEditComponent } from './components/main/content/game-group-edit/game-group-edit.component';
import {StatusPipe} from '../ng-tools/src/components/badge/status.pipe';
import { PersonalGroupComponent } from './components/main/content/personal-group/personal-group.component';
import { GameTypeChooseComponent } from './components/main/content/game-type-choose/game-type-choose.component';
import { AccountDetailComponent } from './components/main/content/account-detail/account-detail.component';
import { PlatformStatisticComponent } from './components/main/content/platform-statistic/platform-statistic.component';
import { PersonalGroupDetailComponent } from './components/main/content/personal-group-detail/personal-group-detail.component';
import { PersonalGroupEditComponent } from './components/main/content/personal-group-edit/personal-group-edit.component';
import { ChargeStyleComponent } from './components/main/content/charge-style/charge-style.component';
import { ChargeStyleAddAndEditComponent } from './components/main/content/charge-style-add-and-edit/charge-style-add-and-edit.component';

registerLocaleData(zh);

export const configFilePath = new InjectionToken('config file', {factory: () => 'config.json'});


const serverConfigProvider = {
  provide: ServerConfigService,
  useFactory: serverConfigFactory,
  deps: [HttpClient, configFilePath]
};


@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    MainComponent,
    NavbarComponent,
    MenuComponent,
    MenuItemComponent,
    ContentComponent,
    ContextPipe,
    CnTransPipe,
    ThemeComponent,
    CopyrightComponent,
    PlatformInfoComponent,
    UserManagerComponent,
    ChargeManagerComponent,
    ChargeRecordComponent,
    MoneyManagerComponent,
    MoneyRecordComponent,
    EditNoticeComponent,
    UserServiceComponent,
    UserBankComponent,
    SystemSetComponent,
    GameGroupComponent,
    RobotGroupComponent,
    RobotManagerComponent,
    RobotEditComponent,
    RobotProduceComponent,
    RobotGroupListComponent,
    RobotGroupItemAddComponent,
    RobotGroupItemConfigComponent,
    GameGroupEditComponent,
    PersonalGroupComponent,
    GameTypeChooseComponent,
    AccountDetailComponent,
    PlatformStatisticComponent,
    PersonalGroupDetailComponent,
    PersonalGroupEditComponent,
    ChargeStyleComponent,
    ChargeStyleAddAndEditComponent,
  ],
  imports: [
    BrowserModule,
    RoutesModule,
    BrowserAnimationsModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    AppMessageRegisterModule,
    NgToolsModule,
  ],
  providers: [
    ThemeService,
    ServerTimeService,
    HttpClient,
    serverConfigProvider,
    MenuService,
    UserService,
    {provide: HTTP_INTERCEPTORS, useClass: TokenInterceptorService, multi: true},
    ContextPipe,
    UnitPipe,
    DatePipe,
    StatusPipe,
  ],
  entryComponents: [
    EditNoticeComponent,
    UserServiceComponent,
    UserBankComponent,
    RobotEditComponent,
    RobotProduceComponent,
    RobotGroupItemAddComponent,
    RobotGroupItemConfigComponent,
    GameTypeChooseComponent,
    AccountDetailComponent,
    PersonalGroupEditComponent,
    ChargeStyleAddAndEditComponent,
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}
